package com.ys.http.utils;

import java.util.HashMap;
import java.util.Map;

public class MapBuilder {

    private final Map<String, String> mMaps;

    public static MapBuilder newBuilder() {
        return new MapBuilder();
    }

    public MapBuilder () {
        mMaps = new HashMap<>();
    }

    public MapBuilder add(String name, String value) {
        if (isValidate(name, value)) {
            mMaps.put(name, value);
        }
        return this;
    }

    public MapBuilder add(String name, Number value) {
        if (isValidate(name, value)) {
            mMaps.put(name, value.toString());
        }
        return this;
    }

    public MapBuilder add(String name, boolean value) {
        if (name != null) {
            mMaps.put(name, String.valueOf(value));
        }
        return this;
    }

    private boolean isValidate(String name, Object value) {
        return name != null && value != null;
    }

    public Map<String, String> get() {
        return mMaps;
    }
}
